<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="button" value="平方" onclick="f1()">
<div>结果:<span></span></div>


<script>

  function f1() {
    let a = document.querySelector("#i1");
    let b = document.querySelector("span");
    if(isNaN(a.value)) {
      b.innerText="输入有误";
      return;
    }
    // b.innerText = ""+a.value*a.value;
   /* b.innerText = a.value*1+a.value*1;*/
      b.innerText = parseFloat(a.value)+parseFloat(a.value);
  }

</script>
</body>
</html>